<?php
/**
 * 描述
 * Created by Paco
 * Date: 2019/1/29 Time: 16:02
 */

namespace App\Http\Controllers\Shop;


use App\Http\Controllers\Controller;
use App\Http\Request\Shop\ShopStore;
use App\Repositories\Shop\ShopRepository;
use Illuminate\Http\Request;

class ShopController extends Controller
{
    private $shop;

    public function __construct(ShopRepository $shop)
    {
        $this->shop = $shop;
    }

    public function show()
    {
        return $this->shop->show();
    }


    /**
     *
     * store
     * author Paco
     * createTime 2019/1/29 16:23
     * @param ShopStore $shop
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(ShopStore $shop, Request $request)
    {
        $params = $shop->validated($request);
        return $this->shop->store($params);
    }

    /**
     *
     * update
     * author Paco
     * createTime 2019/1/29 16:23
     * @param ShopStore $shop
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function update(ShopStore $shop, Request $request)
    {
        $params = $shop->validated($request);
        $params['checked'] = 0;
        return $this->shop->update($params);
    }
}